﻿using NPOI.HSSF.Record;
using System;
using System.Collections.Generic;
using System.Reflection;

namespace Hydrogen.MarkovChain
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class RuleNodeNameAttribute:Attribute
    {
        public string Name { get;}

        public RuleNodeNameAttribute(string name)
        {
            this.Name = name;
        }

        public static Dictionary<RuleNodeNameAttribute,Type> GetTypes(Assembly[] ass,params Type[] extendFrom)
        {
            List<Type> types = new List<Type>();
            List<RuleNodeNameAttribute> attributes = new List<RuleNodeNameAttribute>();
            ULib.ReflectionUtility.GetClassByAttribute(ref types, ref attributes, ass, extendFrom);
            Dictionary<RuleNodeNameAttribute, Type> result = new Dictionary<RuleNodeNameAttribute, Type>();
            for (int i = 0; i < types.Count; i++)
            {
                result[attributes[i]] = types[i];
            }

            return result;
        }
    }
}
